package com.heima.wemedia.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;

import javax.xml.ws.Service;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.function.Function;

public class WmSensitiveServiceImpl implements WmSensitiveService {

    @Override
    public ResponseResult insert(WmSensitive wmSensitive) {
        if (wmSensitive==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }

        //已存在的敏感词，不能保存
        WmSensitive sensitive = getOne(Wrappers.<WmSensitive>lambdaQuery().eq(WmSensitive::getSensitives, wmSensitive.getSensitives()));
        if (sensitive!=null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID,"敏感词已存在");
        }
        //保存
        wmSensitive.setCreatedTime(new Date());
        save(wmSensitive);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

    @Override
    public boolean saveBatch(Collection<WmSensitive> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<WmSensitive> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<WmSensitive> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(WmSensitive entity) {
        return false;
    }

    @Override
    public WmSensitive getOne(Wrapper<WmSensitive> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<WmSensitive> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<WmSensitive> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public BaseMapper<WmSensitive> getBaseMapper() {
        return null;
    }

    @Override
    public Class<WmSensitive> getEntityClass() {
        return null;
    }
}
